package gui;

import processing.core.PApplet;

public class Point {

	private int posX;
	private int posY;
	private int color;
	
	private boolean selected;
	private boolean highlighted;
	
	public static final int SIZE = 5;
	
	private PApplet mainApplet;
	
	public Point()
	{
		selected = false;
		highlighted = false;
	}
	
	public Point(int posX, int posY, int color, PApplet mainApplet)
	{
		this.posX = posX;
		this.posY = posY;
		this.color = color;
		this.mainApplet = mainApplet;
	}
	
	public boolean overPoint (){
		float disX = posX - mainApplet.mouseX;
		float disY = posY - mainApplet.mouseY;

		if(PApplet.sqrt(PApplet.sq(disX) + PApplet.sq(disY)) < SIZE) {
			return true;
		}else{
			return false;
		}
	}
	
	public void setSelected()
	{
		selected = true;
	}
	
	public void setUnselected()
	{
		selected = false;
	}
	
	public boolean isSelected()
	{
		return selected;
	}
	
	public void setHiglighted()
	{
		highlighted = true;
	}
	
	public void setUnhighlighted()
	{
		highlighted = false;
	}
	
	public void drawPoint()
	{
		int pointSize = SIZE;
		mainApplet.stroke(color);
		if(selected)
		{
			mainApplet.fill(color);
			pointSize *= 2;
		}
		else if(highlighted)
		{
			mainApplet.fill(color);
		}
		else
		{
			mainApplet.noFill();
		}
		mainApplet.ellipse (posX, posY, pointSize, pointSize);
	}
	
}
